#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n, i;
	string name[10010];
	double num[10010];
	cin >> n;
	double avg = 0;
	for(i = 0; i < n; i++)
	{
		cin >> name[i] >> num[i];
		avg += num[i]; 
	}
	avg /= n*2;
	int index = 0, min = abs(avg - num[0]);
	for(i = 1; i < n; i++)
	{
		if(abs(avg - num[i]) < min)
		{
			index = i;
			min = abs(avg - num[i]);
		}
	}
	printf("%.0f", avg);
	cout << " " << name[index];
	return 0;
} 
